package com.fy.fyspace.model.enums.space;

public enum SpaceStatusEnum {
    IS_DELETE(1, "被禁用"),
    IS_NORMAL(0, "正常");

    private final int code;
    private final String desc;

    SpaceStatusEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static SpaceStatusEnum getByCode(int code) {
        for (SpaceStatusEnum status : values()) {
            if (status.code == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("No enum constant with code: " + code);
    }

    public static SpaceStatusEnum getByDesc(String desc) {
        for (SpaceStatusEnum status : values()) {
            if (status.desc.equals(desc)) {
                return status;
            }
        }
        throw new IllegalArgumentException("No enum constant with description: " + desc);
    }

    @Override
    public String toString() {
        return "SpaceStatusEnum{" +
                "code=" + code +
                ", desc='" + desc + '\'' +
                '}';
    }
}
